package org.example.struct.array2;

import java.util.Arrays;

/**
 * @author liyishan
 * @date 2024/8/14 09:19
 * @apiNote
 */

public class Test03152IsArraySpecial {

    public boolean[] isArraySpecial(int[] nums, int[][] queries) {
        int n = nums.length;
        int[] dp = new int[n];
        Arrays.fill(dp,1);
        for(int i = 1;i<n;i++){
            if(((nums[i] ^ nums[i-1]) & 1)!=0){
                dp[i] = dp[i-1]+1;
            }
        }
        boolean[] res = new boolean[queries.length];
        for(int i =0;i<queries.length;i++){
            int x = queries[i][0];
            int y = queries[i][1];
            res[i] = dp[y] >= y-x+1;
        }
        return res;
    }

}
